/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: happyiu
 * Date: 2021-11-10
 * Time: 21:12
 */


class Person {
    public int age;//成员属性 实例变量
    public String name;
    public String sex;
    public void eat() {//成员方法
        System.out.println("吃饭!");
    }
    public void sleep() {
        System.out.println("睡觉!");
    }
}

public class TestDemo {

/*    class Person1 {
        public int age;//成员属性 实例变量
        public String name;
        public String sex;
        public void eat() {//成员方法
            System.out.println("吃饭!");
        }
        public void sleep() {
            System.out.println("睡觉!");
        }
    }*/


        public static void main(String[] args) {
            Person person1 = new Person();//通过new实例化对象
            person1.eat();//成员方法调用需要通过对象的引用调用
            person1.sleep();
            //产生对象     实例化对象
            Person person2 = new Person();
            person2.name="hell";
            person2.age=18;
            System.out.println(person2.name);
            System.out.println(person2.age);
            Person person3 = new Person();
        }







}
